(use-package q4
  :load-path "/home/qrthi/documents/projects/elisp/q4"
  :demand t
  :bind
  ("C-c u q" . q4/browse-board)
  (:map q4-mode-map
	("v" . q4/open-item)
	;; ("l" . q4/go-back)
	("d" . q4/wget-threadpics)
	("&&" . q4/view-content-externally)
	("C-c C-s" . q4/browse-board))
  :custom
  (q4/photo-download-directory (expand-file-name "pictures/gallery-dl/4chan/" qrthi/directory-media))
  :init
  (defun qrthi/wget-threadpics (&optional name)
    ;; changed filename
    (interactive)
    (let ((pics (q4/threadpics-string)))
      (if pics
	  (let* ((input
		  (or name (read-string
			    (format "(Folder Name)> %s"
				    q4/photo-download-directory))))
		 (path
		  (expand-file-name
		   (if (string= input "")
		       (format "%s/%s" q4/board q4/threadno)
		     input)
		   q4/photo-download-directory)))
	    (start-process-shell-command
	     "q4-wget" nil (format "DEST=%s; mkdir $DEST; cd $DEST; wget %s"
				   path pics)))
	(message "No photos in this buffer."))))
  :config
  (defalias 'q4/wget-threadpics 'qrthi/wget-threadpics))
